﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;
using DAL;
using Tencent;
using System.Xml;
namespace UI
{
    public partial class authorize_wx : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string appid = "wxef2c55ebada8928b";
            string aeskey = "3E5y3Y8OFWSmHvkNJdANdXKJc6qH7hoygs6qNHpg3FB";
            string token = "yixiaoke";

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(Request.InputStream);
            string xml = xmlDoc.InnerXml;
            string postData = xml;

            string sMsg = "";//解密后的内容
            var msg = new WXBizMsgCrypt(token, aeskey, appid);
            int ret = msg.DecryptMsg(
            Request.QueryString["msg_signature"],
            Request.QueryString["timestamp"],
            Request.QueryString["nonce"],
            postData,
            ref sMsg);

            Commons.Log2(sMsg);

            WeiXin wx = new WeiXin();
            dynamic obj = wx.ConvertJson(wx.XmlToJson(sMsg));
            Commons.Log2(obj.ComponentVerifyTicket);
            ConfigDAL.UpdateThirdTicket(obj.ComponentVerifyTicket);
            Response.Write("success");
        }
    }
}